<template>
  <div id="topSearch">
    <h1 class="con-right-title">
      频道设置
    </h1>
    <div class="search-box">
      <el-form
        ref="ruleForm"
        :rules="rules"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item label="" prop="name">
          <el-input v-model="formInline.name" placeholder="请输入频道名称搜索">
          </el-input>
        </el-form-item>
        <el-form-item class="s-btn">
          <el-button
            type="success"
            icon="el-icon-search"
            @click="toSearch('ruleForm')"
          >
            查询
          </el-button>
          <el-button type="success" plain @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TopSearch',
  msg: '频道设置-顶部搜索',
  props: {
    formInline: {
      type: Object,
      default: function() {
        return {
          name: '' // 标签名称
        }
      }
    }
  },
  data() {
    return {
      rules: {
        name: {}
      }
    }
  },
  mounted() {},
  methods: {
    /* 搜索 */
    toSearch(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('toSearch')
        } else {
          return false
        }
      })
    },
    /* 重置 */
    reset() {
      this.$refs['ruleForm'].resetFields()
    }
  }
}
</script>

<style lang="less">
#topSearch {
  .search-box {
    padding-left: 30px !important;
  }
}
</style>
